/**
 * @author: wq
 * @Date: 2017/12/15
 * @Time: 14:40
 * <p>
 * Description:
 *          整车司机 API
 */

import axios from 'axios';
import { ALL_SERVICE_API } from '../api';

var qs = require('qs');

/**
 * 获取整车司机对象
 * @param id
 * @returns {AxiosPromise}
 */
export const getTruckLoadDriver = id => {
  return axios.get(ALL_SERVICE_API + '/truck-load-drivers/' + id);
};

/**
 * 获取整车司机对象,含司机认证信息
 * @param id
 * @returns {AxiosPromise}
 */
export const getTruckLoadDriverDetail = id => {
  return axios.get(ALL_SERVICE_API + '/truck-load-drivers/' + id + '/detail');
};

/**
 * 获取整车司机列表
 * @param params
 * @returns {AxiosPromise}
 */
export const searchTruckLoadDrivers = (params) => {
  return axios.get(ALL_SERVICE_API + '/truck-load-drivers/admin', {params: params});
};

/**
 * 新增整车司机
 * @param params
 * @returns {AxiosPromise}
 */
export const saveTruckLoadDriver = params => {
  return axios.post(ALL_SERVICE_API + '/truck-load-drivers', params);
};

/**
 * 修改整车司机
 * @param params
 * @returns {AxiosPromise}
 */
export const updateTruckLoadDriver = params => {
  return axios.put(ALL_SERVICE_API + '/truck-load-drivers', params);
};

/**
 * 修改整车司机状态
 * @param params
 * @returns {AxiosPromise}
 */
export const changeDriveStatus = (id, status) => {
  return axios.post(ALL_SERVICE_API + '/truck-load-drivers/change', qs.stringify({id: id, status: status}));
};

/**
 * 修改司机认证状态
 * @param id
 * @param status
 * @returns {AxiosPromise}
 */
export const changeDriveAuthenticationStatus = (id, status, description) => {
  return axios.post(ALL_SERVICE_API + '/truck-load-driver-authentications/change', qs.stringify({
    id: id,
    status: status,
    description: description
  }));
};

/**
 * 手工提交整车司机的认证信息
 * @param param
 * @returns {AxiosPromise<any>}
 */
export const createAuthentication = param => {
  return axios.put(ALL_SERVICE_API + '/truck-load-driver-authentications', param);
};

/**
 * 获取司机合作领头羊列表
 * @param phone
 * @returns {AxiosPromise}
 */
export const searchCooperateBellwethers = (params) => {
  return axios.get(ALL_SERVICE_API + '/cooperate-bellwethers/', {params: params});
};
